home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 9
/
009.d81
/
dos #21
< prev
next >
Wrap
Text File
|
2022-08-26
|
2KB
|
139 lines
DOS and DON'TS -- PART 21
==========================
by Jimmy Weiler
The command to open a RELative file
is similar to that used for a SEQ file
OPEN <file number>,<device number>,
<channel number>,<file name>",L,"
CHR$(<record length>)
That's a bit overwhelming so lets
simplify it with an example and then
cover it a piece at a time.
OPEN 3,8,4,"PHONEFILE,L,"+CHR$(89)
"OPEN" tells DOS to prepare to use
the file. The file will be number
"3", so any PRINT# or INPUT# or GET#
statements intended for that file will
have to use #3. The device number is
"8" -- that's just the disk unit
number. For most of us it is always
8. "4" is the channel number. That
tells DOS which pathway to take to get
to the disk. You will have to use the
channel number again and again as you
access a relative file. "PHONEFILE"
is the name of the relative file. It
will appear in the disk directory,
followed by ":REL".
Up to this point, the syntax has
been the same as for a SEQuential type
file. The last part of a RELative
file open statement is the only
distinction. The "L" or length
parameter tells DOS how many
characters each record of the REL
file will hold.
In our example, ",L,"+CHR$(89)
establishes each record as 89
characters long. The reason I
chose 89 is that INPUT# will accept
inputs up to 88 characters in length
from a disk file. The extra character
is for the carriage return that will
mark the end of input when we read
the file. You can use any record
length from 1 to 254 characters,
except 58 -- 58 produces a syntax
error. (More on this oddity later.)
When you create REL files, you need
to know the maximum amount of data
that will ever be written to a record
and the number of "fields" each record
will have. Let's say we were making
a file of the last name and phone
number of everybody in our class at
school. All their phone numbers are
seven digits long, so that's no
problem, but the names will vary in
length. We have to take the longest
name we expect to find and make room
for that in each record.
It turns out that Joe Schlabotnik
has the longest name in my class, so
I have to allow 11 characters for the
"name field" in each record.
------- Continued in Part 22 ---------